/*class MyArray {
    public Object[] array = new Object[10];

    public void setValue(int pos,Object val) {
        array[pos] = val;
    }

    public Object getVal(int pos) {
        return array[pos];
    }

}*/
//<E> 占位符 ：表示当前类 是一个泛型类
class MyArray<E extends Number> {
    public Object[] array = new Object[10];

    public void setValue(int pos,E val) {
        array[pos] = val;
    }

    public E getVal(int pos) {
        return (E)array[pos];
    }
}
public class Test2 {


    public static void main(String[] args) {
        /*Test2 test2 = new Test2();
        System.out.println(test2);*/

        MyArray<Integer> myArray = new MyArray<>();
        System.out.println(myArray);

        /*MyArray<String> myArray2 = new MyArray<>();
        System.out.println(myArray2);*/

    }


    /*public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setValue(0,10);
        myArray.setValue(1,20);
        //myArray.setValue(1,"hello");//自动类型检查
        Integer a = myArray.getVal(1);//自动类的转换
        System.out.println(a);

        System.out.println("========");
        MyArray<String> myArray2 = new MyArray<>();
        myArray2.setValue(0,"hello");
        myArray2.setValue(1,"abc");
        String str = myArray2.getVal(0);
        System.out.println(str);

    }*/
    /*public static void main(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setValue(0,10);
        myArray.setValue(1,"hello");

        String str = (String)myArray.getVal(1);
        System.out.println(str);
    }*/
}